package edu.unc.comp410.colemangeer.model;

import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;

public enum ProductCategory {
	MAGICAL,SOFTWARE,BOOK,WEAPON,MISC;


public static ProductCategory getCategoryByName (String name){
	name = name.trim();
	
	if (name.equalsIgnoreCase("magical")){
		return MAGICAL;
	}
	else if (name.equalsIgnoreCase("software")){
		return SOFTWARE;
	}
	
	else if (name.equalsIgnoreCase("book")){
		return BOOK;
	}
	else if (name.equalsIgnoreCase("weapon")){
		return WEAPON;
	}
	else if (name.equalsIgnoreCase("misc")){
		return MISC;
	}
	else{
		throw new IllegalArgumentException();
	}
}
public static EnumSet<ProductCategory> buildCategorySet(List<ProductCategory> categories){
	EnumSet<ProductCategory> result = EnumSet.noneOf(ProductCategory.class);
	for (ProductCategory cat: categories){
		result.add(cat);
	}
	return result;
}
public static List<ProductCategory> buildCategoryList(List<String> categories) {
	
	List<ProductCategory> categoryList= new ArrayList<ProductCategory>();
	
	for (String catString: categories){
		categoryList.add(ProductCategory.getCategoryByName(catString));
	}
	
	return categoryList;
}

/*public static EnumSet<ProductCategory> buildCategorySet(List<String> categories){
	EnumSet<ProductCategory> result = EnumSet.noneOf(ProductCategory.class);
	
	for (String cat: categories){
		try {
			ProductCategory enumCat = (ProductCategory.getCategoryByName(cat));
			result.add(enumCat);
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		}
		
	}
	return result;
}*/


}